local ClientOHOH = _G.ClientOHOH;
local M = ClientOHOH.class.new(script, ClientOHOH.files.Client_PlayerComponent(),script.Parent.Name);
local EventList = ClientOHOH.load.EventList();

local CallBackManager = ClientOHOH.load.CallBackManager();

function M.new(self,...)
	return M(self,...);
end;

function M.ctor(self, parent)
	M.super.ctor(self, parent);
    self.player=parent
	self:AddProcess(function()    
        local touchPart=ClientOHOH:GetPath_Loop("Scene.1.PVPTouch.1.Touch",game.Workspace)
        CallBackManager:AddRbxConnect(self,touchPart.Touched, function(obj,otherPart)
            if not _G.CommonOHOH.load.GeneralTool().IsMeTouchEvent(otherPart,"LeftLowerLeg") then
                return 
            end
			if self.player.main_inst.Character.Humanoid.Health <= 0 then
				return
			end
			-- local playerInst=GeneralTool.TouchPlayerEvent(otherPart)
			if self.player  then
				-- print("生命",self.player.main_inst.Character)
				-- print("生命",self.player.main_inst.Character.Humanoid.Health)
				-- self.player:GetComponent(_G.CommonOHOH.load.Common_PVPBattlCtrl()):EnterPvPTestScene(true);
				self.player:GetComponent(_G.CommonOHOH.load.Common_PVPBattlCtrl()):EnterPvPScene();
				--    local player= InstanceManager:FindObject(playerInst)
			   -- player:GetComponent(_G.CommonOHOH.load.Common_PVPBattlCtrl()):EnterPvPScene()
			end
        end);
    end)
end;

function M.dtor(self)
	M.super.dtor(self);
end;
function M.EnterPvPScene(self,isWin,rivalId,myCarData,rivalCarData)
	print("————————————————————走客户端进入PK场景——————————————————————")
	local success = self.parent.LeaveHomeEvent:Action()
	while not success do
		task.wait(0,1)
	end
	print("删除车辆成功 创建赛道")
	self.player:GetComponent(_G.CommonOHOH.load.Common_PVPTrackCtrl()):CreatePVPTrack(isWin,rivalId,myCarData,rivalCarData)
end
function M.EnterPvPTestScene(self,isWin)
	print("走客户端进入PK 测试 场景")
	self.player:GetComponent(_G.CommonOHOH.load.Common_PVPTrackCtrl()):CreatePVPTestTrack(isWin)
end


return M